package com.ztmg.water.config.filter;

import com.ztmg.common.constant.CommonConstants;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


    @Component
    @Order(1)
    @WebFilter(urlPatterns = {"/*", "/api/v1/userinfo/*"})
    public class AuthTokenFilter implements Filter {

//        @Autowired
//        private AuthTokenService authTokenService;

        @Override
        public void init(FilterConfig var1) throws ServletException {

        }

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                throws IOException, ServletException {
            HttpServletRequest req = (HttpServletRequest) request;

            String token = req.getHeader(CommonConstants.WATER_TOKEN);

//            BizResult<String> bizResult = authTokenService.powerCheck(token);

//            System.out.println(SerializeUtil.Serialize(bizResult));

//            if (bizResult.getIsOK() == true) {
//                PowerLogger.info("auth token filter passed");

                chain.doFilter(request, response);
//            } else {
//                throw new ServletException(bizResult.getMessage());
//            }

        }


        @Override
        public void destroy() {

        }
    }
